package com.leyou.pay.controller;

import com.leyou.pay.entity.AliPayParam;
import com.leyou.pay.entity.PayState;
import com.leyou.pay.entity.WxPayParam;
import com.leyou.pay.service.AliPayService;
import com.leyou.pay.service.WxPayService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("getLyPay")
public class PayController {

    @Autowired
    private WxPayService wxPayService;
    @Autowired
    private AliPayService aliPayService;

    @PostMapping("wxPay")
    public String wxPay(@RequestBody WxPayParam payParam){
        return this.wxPayService.getUrl(payParam);
    }

    @PostMapping("aliPay")
    public String aliPay(@RequestBody AliPayParam payParam){
        return this.aliPayService.getHtml(payParam);
    }

    @PostMapping("queryWxStatus")
    public PayState queryPayStatus(@RequestParam("orderId") Long orderId){
        return this.wxPayService.queryPayStatus(orderId);
    }
}
